<?php
class Address extends CActiveRecord
{
     public $latitude;
  public $longitude;
  public $map_zoom_level;
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Business the static model class
	 */
  public  function store_location($business_id,$latitude,$longitude,$map_zoom_level)
  {
  $sql="INSERT INTO tbl_business_location(business_id,latitude,longitude,map_zoom_level,create_time,update_time) VALUES('".$business_id."','".$latitude."','".$longitude."','".$map_zoom_level."','".$create_time."','".$update_time."')'";
   $command=Yii::app()->db->createCommand($sql);
   return $command->execute()==1?true:false;
   
  }
  
  
  
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_business_location';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('business_id, latitude, longitude, map_zoom_level, create_time, update_time', 'required'),
			array('business_id, map_zoom_level', 'numerical', 'integerOnly'=>true),
			array('latitude, longitude', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, business_id, latitude, longitude, map_zoom_level, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'business_id' => 'Business',
			'latitude' => 'Latitude',
			'longitude' => 'Longitude',
			'map_zoom_level' => 'Map Zoom Level',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('business_id',$this->business_id);
		$criteria->compare('latitude',$this->latitude);
		$criteria->compare('longitude',$this->longitude);
		$criteria->compare('map_zoom_level',$this->map_zoom_level);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}

?>